gdksurface-win32.c: Add function to handle queued moves/resizes
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 5 Aug 2020 02:36:53 +0000 (10:36 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 5 Aug 2020 08:23:12 +0000 (16:23 +0800)
Since we need to deal with queued moves and resizes in the Cairo, GL and Vulkan
draw contexts, and the logic involved in all three of these are largely
similar, add a function gdk_win32_surface_handle_queued_move_resize() that will
handle this, which will be shared between these three types of draw contexts.

gdk/win32/gdksurface-win32.c
gdk/win32/gdksurface-win32.h

index 357bfd813ed8a9aa04c71093401cccc6a33b783f..9aa33b96ac51b8b903c3b831119d73d885c1c305 100644 (file)
@@ -45,6 +45,7 @@
 #include "gdkwin32cursor.h"
 #include "gdkglcontext-win32.h"
 #include "gdkdisplay-win32.h"
+#include "gdkcairocontext-win32.h"
 
 #include <cairo-win32.h>
 #include <dwmapi.h>
@@ -5147,3 +5148,41 @@ gdk_win32_surface_apply_queued_move_resize (GdkSurface *surface,
   /* Don't move iconic windows */
   /* TODO: use SetWindowPlacement() to change non-minimized window position */
 }
+
+RECT
+gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context)
+{
+  GdkWin32CairoContext *cairo_ctx = NULL;
+  GdkSurface *surface;
+  GdkWin32Surface *impl;
+  int scale;
+  RECT queued_window_rect;
+
+  surface = gdk_draw_context_get_surface (draw_context);
+  impl = GDK_WIN32_SURFACE (surface);
+  scale = gdk_surface_get_scale_factor (surface);
+
+  if (GDK_IS_WIN32_CAIRO_CONTEXT (draw_context))
+    {
+      cairo_ctx = GDK_WIN32_CAIRO_CONTEXT (draw_context);
+      cairo_ctx->layered = impl->layered;
+    }
+
+  gdk_win32_surface_get_queued_window_rect (surface, scale, &queued_window_rect);
+
+  /* Apply queued resizes for non-double-buffered and non-layered windows
+   * before painting them (we paint on the window DC directly,
+   * it must have the right size).
+   * Due to some poorly-undetstood issue delayed
+   * resizing of double-buffered windows can produce weird
+   * artefacts, so these are also resized before we paint.
+   */
+  if (impl->drag_move_resize_context.native_move_resize_pending &&
+      (cairo_ctx == NULL || !cairo_ctx->layered))
+    {
+      impl->drag_move_resize_context.native_move_resize_pending = FALSE;
+      gdk_win32_surface_apply_queued_move_resize (surface, queued_window_rect);
+    }
+
+  return queued_window_rect;
+}
index e4f97d11bea3e8f38bd83f49538eca42a8fb0c2b..7fb35ed7643affb64df9cc6467d92b88922511f0 100644 (file)
@@ -393,6 +393,9 @@ void gdk_win32_surface_move_resize (GdkSurface *window,
                                     int         width,
                                     int         height);
 
+RECT
+gdk_win32_surface_handle_queued_move_resize (GdkDrawContext *draw_context);
+
 void
 gdk_win32_surface_get_queued_window_rect (GdkSurface *surface,
                                           int         scale,